package pvz.a;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;

import org.standard.Utility;

public class PlantImage extends PVZImage implements Cloneable {
	public PlantImage(String name) {
		String fileName = "pvz/images/Plants/" + name + "/" + name + ".gif";
		this.setImage(Utility.loadImage(fileName));
		this.setWidth(this.getImage().getWidth(null));
		this.setHeight(this.getImage().getHeight(null));
	}

	public PlantImage(String name, int x, int y) {
		String fileName = "pvz/images/Plants/" + name + "/" + name + ".gif";
		this.setImage(Utility.loadImage(fileName));
		this.setWidth(this.getImage().getWidth(null));
		this.setHeight(this.getImage().getHeight(null));
		this.setPosX(x);
		this.setPosY(y);
	}

	public void getImageTransparent() {
		Image bufimg = Utility.createImage(this.getWidth(), this.getHeight(),
				true);
		Graphics2D graphics = (Graphics2D) bufimg.getGraphics();
		AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
				0.5f);
		graphics.setComposite(ac);
		graphics.drawImage(bufimg, 0, 0, null);
	}

	@Override
	public Object clone() throws CloneNotSupportedException {
		return super.clone();
	}
}
